# 1. 导入需要的包
from time import sleep
from selenium import webdriver

# 2. 创建浏览器对象,并打开网页
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.baidu.com/")
# 2.1 添加和登录相关的cookie
cookies = [
    {"name": "BDUSS",
     "value": "Hc5dWlCfmNnaG55cUp0S2ROQkpkTG5UMVEwdkF1YVNVUzdwTlR3N0hId2NEVHBrSUFBQUFBJCQAAAAAAAAAAAEAAABT3rS7ztLT0M7ezuXQ0Me3tPIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAByAEmQcgBJkU"},
    {"name": "BDUSS_BFESS",
     "value": "Hc5dWlCfmNnaG55cUp0S2ROQkpkTG5UMVEwdkF1YVNVUzdwTlR3N0hId2NEVHBrSUFBQUFBJCQAAAAAAAAAAAEAAABT3rS7ztLT0M7ezuXQ0Me3tPIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAByAEmQcgBJkU"}
]
for cookie in cookies:
    driver.add_cookie(cookie)

# 2.2 刷新网页
driver.refresh()

# 3. 关闭浏览器
sleep(10)
driver.quit()
